﻿#ifndef CHECKDELEGATE_H_
#define CHECKDELEGATE_H_

#include <QStyledItemDelegate>
#include <QCheckBox>
#include <QStyleOption>
#include <QApplication>
#include <QMouseEvent>



class CheckDelegate : public QStyledItemDelegate
{
	Q_OBJECT
private:
	size_t m_checkcount{};		//选中的item的数量

signals:
	void stateChanged(int state, const QModelIndex& index);
public:
	CheckDelegate(QObject* parent = nullptr);
	void setCheckCount(size_t count);
	size_t CheckCount()const;

protected:
	void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
	bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
};


#endif // !CHECKDELEGATE_H_
